import mongoose from 'mongoose'
import config from '../config'
import Wechat from '../wechat-lib'
import Oauth from '../wechat-lib/oauth'
const Token = mongoose.model('Token')
const Ticket = mongoose.model('Ticket')
const {wechat:{appID,appsecret}} = config
// 微信入口配置
const wechatConfig = {
    appID,
    appsecret,
    getAccessToken:async () =>await Token.getAccessToken(),
    saveAccessToken:async (data) =>await Token.saveAccessToken(data),
    getTicket:async () =>await Ticket.getTicket(),
    saveTicket:async (data) =>await Ticket.saveTicket(data)
}

// 微信启动项
export const getWechat = () => {
    return new Wechat(wechatConfig)
}

// 微信启动项
export const getOauth = () => {
    return new Oauth(wechatConfig)
}